# 部署脚本
#!/bin/bash
# deploy.sh

echo "🚀 部署动态多目标投资组合优化系统"

# 检查Docker是否安装
if ! command -v docker &> /dev/null; then
    echo "❌ Docker未安装，请先安装Docker"
    exit 1
fi

# 检查Docker Compose是否安装
if ! command -v docker-compose &> /dev/null; then
    echo "❌ Docker Compose未安装，请先安装Docker Compose"
    exit 1
fi

# 创建必要的目录
mkdir -p models logs results

# 构建并启动服务
echo "📦 构建Docker镜像..."
docker-compose build

echo "🔧 启动服务..."
docker-compose up -d

# 检查服务状态
sleep 10
if curl -s http://localhost:8000/health > /dev/null; then
    echo "✅ 服务启动成功！"
    echo "📡 API服务: http://localhost:8000"
    echo "📖 API文档: http://localhost:8000/docs"
else
    echo "❌ 服务启动失败，请检查日志："
    docker-compose logs
    exit 1
fi

echo "🎉 部署完成！"
